﻿@using Microsoft.AspNet.Identity
@if (Request.IsAuthenticated)
{
    using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-form pull-right" }))
    {
        @Html.AntiForgeryToken()

        <ul class="nav">
            <li id="img-login">
                <span>
                    @{
                        var username = User.Identity.GetUserName();
                        Scorpicore.Data.DataContext db = new Scorpicore.Data.DataContext();
                        var img = db.Users.FirstOrDefault(u => u.UserName == username).AvatarUrl;
                    }
                    @if(img == null)
                    {
                        <img src="../Avatars/default.jpg" style="width: 30px; height: 30px; margin-top: 2.2%;" />
                    } 
                    else if (img.Contains("default.jpg"))
                    {
                        <img src="../Avatars/default.jpg" style="width: 30px; height: 30px; margin-top: 2.2%;" />
                    }
                    else
                    {
                        <img src="../Avatars/@User.Identity.GetUserName()/@(User.Identity.GetUserName()).png" style="width:30px;height:30px;margin-top:2.2%;" />
                    }
                                    @Html.ActionLink(User.Identity.GetUserName(), "Manage", "Account", new { area = "" }, htmlAttributes: new { title = "Manage" })
                </span>
            </li>

            <li id="text-exit"><a href="javascript:document.getElementById('logoutForm').submit()">Изход</a></li>
        </ul>
    }
}
else
{
    <ul class="nav pull-right">
        <li>@Html.ActionLink("Регистрация", "Register", "Account", new { area = ""}, htmlAttributes: new { id = "registerLink" })</li>
        <li>@Html.ActionLink("Вход", "Login", "Account", new { area = "" }, htmlAttributes: new { id = "loginLink" })</li>
    </ul>
}
